<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="h" uri="/syzg-html"%>
<%@ taglib prefix="security" uri="http://www.enersun.com.cn/security"%>

<% 
	String realPath = request.getContextPath()+ "/";  
%>
<!DOCTYPE html>
<html>
<body>
<div class="modal fade bs-example-modal-lg" id="addReviewDetailModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">新增审核信息</h4>
      </div>
      <div class="modal-body" id="modalCore">
      	<div class="form-horizontal" id="reviewPass" style="text-align: center;">审核已通过！</div>
        <form class="form-horizontal" role="form" id="aeForm" name="aeForm">
          <security:CSRF/>
          <fieldset>
            <!-- generate code start -->
            <div class="form-group">
            	<input type="hidden" id="reviewId" name="review.id" value="${reviewdetail.review.id}"/>
            	<input type="hidden" id="busId" name="review.busId" value="${reviewdetail.review.busId}"/>
              	<input type="hidden" id="busMark" name="review.busMark" value="${reviewdetail.review.busMark}"/>
              	<input type="hidden" id="id" name="id" value="${reviewdetail.id}"/>
              	<label class="col-sm-2 control-label" for="state">状态</label>
              	<div class="col-sm-3">
              		<input type="radio" id="state_yes" name="state" value="1" <c:if test="${reviewdetail.state=='1'}">checked="checked"</c:if>/>通过&nbsp;&nbsp;
                	<input type="radio" id="state_no" name="state" value="0" <c:if test="${reviewdetail.state=='0'||reviewdetail.state==null}">checked="checked"</c:if>/>不通过
              	</div>
            </div>

            <div class="form-group">
            	<label class="col-sm-2 control-label" for="busMark">审核意见</label>
              	<div class="col-sm-3">
                	<textarea id="comments" name="comments" class="form-control" style="width: 600px;height: 100px;">${reviewdetail.comments}</textarea>
             	</div>
            </div>

			<!-- generate code end -->
          </fieldset>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" id="saveButton" class="btn btn-primary" onclick="submitSave('add');">保存</button>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript">
$('#aeForm').bootstrapValidator({
  message: 'This value is not valid',
  feedbackIcons: {
      valid: 'glyphicon glyphicon-ok',
      invalid: 'glyphicon glyphicon-remove',
      validating: 'glyphicon glyphicon-refresh'
  },
  fields: {
      comments: {
    	  group: '.col-sm-3',
          message: '审核内容无效',
          validators: {
              notEmpty: {
                  message: '审核内容不能为空'
              },
              stringLength: {
                  min: 2,
                  max: 100,
                  message: '审核内容长度在2至100个字符之间'
              }
          }
      }
  	}
}).on('success.form.bv', function(e, data) {
	saveReviewDetail();
});
	var saveAddUrl="<%=realPath%>path/review/addreviewdetail";
	/**
	* 保存数据
	*/
	function saveReviewDetail(){
		$.post(saveAddUrl,$("#aeForm").serialize(),function(result){
				if(result.state=='Success'){
					ModalUtil.hideModal("addReviewDetailModal",function(){return true;});
					showAndLoad();
					bootbox.alert("<h4>操作成功！</h4>", function(){
						//刷新待办数量
						 parent.reflashReviewCounter();
					});
				} else {
					bootbox.alert("<h4>操作失败,原因：" + result.content + "</h4>", function(){$('.modal-backdrop').remove();});
				}
		});		
	}
var reviewState='${reviewdetail.review.state}';
if(reviewState=='3'){
	$('#aeForm').hide();
	$('#saveButton').hide();
}else{
	$('#reviewPass').hide();
}
</script>
</body>
</html>